package com.ticket.sass.common.entity.tenant;

import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

/**
 *
 * @author ywb
 * @since 2024-03-07
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("films")
@ApiModel(value="FilmsEntity对象")
public class FilmEntity implements Serializable {
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @ApiModelProperty(value = "影片名")
    private String name;

    @ApiModelProperty(value = "影片封面")
    private String cover;

    @ApiModelProperty(value = "上映时间")
    private LocalDate releaseDate;

    @ApiModelProperty(value = "上映地区")
    private String releaseArea;

    @ApiModelProperty(value = "导演")
    private String director;

    @ApiModelProperty(value = "主演员")
    private String actor;

    @ApiModelProperty(value = "类型")
    private String type;

    @ApiModelProperty(value = "片长")
    private Integer duration;

    @ApiModelProperty(value = "剧情描述")
    @TableField("\"desc\"")
    private String desc;

    @ApiModelProperty("影片评分")
    private BigDecimal score;
    
    @ApiModelProperty(value = "来自")
    private String fromUrl;
    
    @ApiModelProperty(value = "来自")
    private Short fromType;
    
    @ApiModelProperty(value = "创建时间")
    @TableField(fill = FieldFill.INSERT)
    public LocalDateTime createdAt;
    
    @ApiModelProperty(value = "更新时间")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    public LocalDateTime updatedAt;
    
    @TableField(select = false)
    @ApiModelProperty(value = "删除时间")
    @TableLogic(value = "null", delval = "now()")
    public LocalDateTime deletedAt;

    @TableField(exist = false)
    private List<FilmVersionEntity> versions;
    
    @TableField(exist = false)
    private Long priceSchemeId;

    @TableField(exist = false)
    private FilmLikeEntity filmLike;

    @TableField(exist = false)
    private Long likeCount;

    public List<FilmVersionEntity> getVersions() {
        if (versions == null) {
            return List.of();
        } else {
            return versions;
        }
    }
}
